// src/api/address.ts
import { http } from '@/utils/http'
import { CustomAddressVo } from './address.d'

/** 地址分页列表 */
export const getAddressList = (params?: { current?: number; size?: number }) => {
  return http<PageResult<CustomAddressVo>>({
    url: '/customer/address/list',
    method: 'GET',
    query: params,
  })
}

/** 添加地址 */
export const addAddress = (data: Omit<CustomAddressVo, 'id'>) => {
  return http<boolean>({
    url: '/customer/address/add',
    method: 'POST',
    data,
  })
}

/** 删除地址 */
export const deleteAddress = (id: number) => {
  return http<boolean>({
    url: `/customer/address/delete/${id}`,
    method: 'DELETE',
  })
}
/** 获取地址详情 */
export const getAddress = (id: number) => {
  return http<CustomAddressVo>({
    url: `/customer/address/info/${id}`,
    method: 'GET',
  })
}
/** 更新地址 */
export const updateAddress = (data: CustomAddressVo) => {
  return http<boolean>({
    url: '/customer/address/update',
    method: 'POST',
    data,
  })
}

/** 获取默认地址详情 */
export const getAddressDefault = () => {
  return http<CustomAddressVo>({
    url: `/customer/address/info/default`,
    method: 'GET',
  })
}
